/*

class Solution {
public:
    ListNode* reverseList(ListNode* head)
    {
        if (!head)
            return nullptr;
        ListNode* prev = nullptr, *cur = head;
        while (cur)
        {
            ListNode* next = cur->next;
            cur->next = prev;
            prev = cur, cur = next;
        }
        return prev;
    }

    bool isPail(ListNode* head) {
        ListNode* slow = head, *fast = head;
        while (fast && fast->next)
        {
            slow = slow->next;
            fast = fast->next->next;
        }
        fast = reverseList(slow->next);
        slow = head;
        while (slow && fast)
        {
            if (slow->val != fast->val)
                return false;
            slow = slow->next;
            fast = fast->next;
        }
        return true;
    }

    class Solution {
public:
    ListNode* oddEvenList(ListNode* head) {
        if (!head)
            return head;
        ListNode* even = head->next, *odd = head, *evenhead = even;
        while (even && even->next)
        {
            odd->next = even->next;
            odd = odd->next;
            even->next = odd->next;
            even = even->next;
        }
        odd->next = evenhead;
        return head;
    }
};
};




#include <iostream>
using namespace std;

int main()
{
    long long a = 0, b = 0, h = 0, k = 0;
    long long num = 0;
    cin >> a >> h >> b >> k;
    while (h > 0 && k > 0)
    {
        num += a + b;
        h -= b;
        k -= a;
        //cout << num << " ";
    }
    if (h <= 0 && k > 0)
    {
        b *= 10;
        num += b;
    }
    else if (h > 0 && k <= 0)
    {
        a *= 10;
        num += a;
    }
    cout << num;

    return 0;
}










*/